package com.quan.common.core.support;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import com.quan.common.base.bean.ResultBean;
import com.quan.common.utils.WebUtils;

public class BaseController {

	protected Logger logger = LoggerFactory.getLogger(this.getClass());

	@Autowired
	protected HttpServletRequest request;

	@Autowired
	protected HttpServletResponse response;
	
	@ExceptionHandler(Exception.class)
	public @ResponseBody Object handleControllerException(HttpServletRequest request, HttpServletResponse response, Throwable e) {
		//处理Ajax请求异常
		
		//返回JSON格式数据
		return ResultBean.errorException(WebUtils.getStatus(request).value(), e.getMessage());
	}

}
